﻿Imports System
Imports System.Windows
Imports System.Windows.Forms
Imports System.Windows.Forms.Control

Namespace XPControl

    Public NotInheritable Class DateTimePicker
        Private Shared Ctrl As System.Windows.Forms.Control

        Public Shared Sub Enable(ByVal Dtp As System.Windows.Forms.DateTimePicker)
            Dtp.Enabled = True
        End Sub

        Public Shared Sub Disable(ByVal Dtp As System.Windows.Forms.DateTimePicker)
            Dtp.Enabled = False
        End Sub

        Public Shared Sub CheckEnable(ByVal chk As System.Windows.Forms.CheckBox, ByVal Dtp As System.Windows.Forms.DateTimePicker)
            If chk.Checked = True Then
                Dtp.Enabled = True
            Else
                Dtp.Enabled = False
            End If
        End Sub

        Public Shared Sub ValueCurrentDate(ByVal Dtp As System.Windows.Forms.DateTimePicker)
            Dtp.Value = Date.Now
        End Sub

        Public Shared Sub EnaBleInGb(ByVal GB As System.Windows.Forms.GroupBox)
            For Each Ctrl As System.Windows.Forms.Control In GB.Controls
                If TypeOf Ctrl Is System.Windows.Forms.DateTimePicker Then Ctrl.Enabled = True
            Next
        End Sub

        Public Shared Sub DisaBleInGb(ByVal GB As System.Windows.Forms.GroupBox)
            For Each Ctrl As System.Windows.Forms.Control In GB.Controls
                If TypeOf Ctrl Is System.Windows.Forms.DateTimePicker Then Ctrl.Enabled = False
            Next
        End Sub

        Public Shared Sub EnaBleInTab(ByVal Tab As System.Windows.Forms.TabPage)
            For Each Ctrl As System.Windows.Forms.Control In Tab.Controls
                If TypeOf Ctrl Is System.Windows.Forms.DateTimePicker Then Ctrl.Enabled = True
            Next
        End Sub

        Public Shared Sub DisaBleInTab(ByVal Tab As System.Windows.Forms.TabPage)
            For Each Ctrl As System.Windows.Forms.Control In Tab.Controls
                If TypeOf Ctrl Is System.Windows.Forms.DateTimePicker Then Ctrl.Enabled = False
            Next
        End Sub

        Public Shared Function CheckMoreCurrentDate(ByVal Dtp As System.Windows.Forms.DateTimePicker, ByVal DataDate As DateTime) As Integer
            If Dtp.Value > DataDate Then
                Dtp.Value = DataDate
                Return 1
            Else
                Return 0
            End If
        End Function
    End Class
End Namespace
